package org.zhuxian.cn.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zhuxian.cn.entity.Inlay;
import org.zhuxian.cn.result.JsonResult;
import org.zhuxian.cn.service.InlayService;

@RestController
@RequestMapping("/inlay")
@Api(tags = "灌注符管理", description = "灌注符相关接口")
public class InlayController {

    @Autowired
    private InlayService inlayServer;

    @ApiOperation(value = "添加灌注符", notes = "添加新的灌注符到系统")
    @PostMapping("/add")
    public JsonResult addInlay(@ApiParam(value = "灌注符信息") @RequestBody Inlay inlay) {
        inlayServer.addInlay(inlay);
        return new JsonResult(200, "OK");
    }

    @ApiOperation(value = "修改灌注符", notes = "更新已存在的灌注符信息")
    @PostMapping("/update")
    public JsonResult modifyInlay(@ApiParam(value = "灌注符信息") @RequestBody Inlay inlay) {
        inlayServer.modifyInlay(inlay);
        return new JsonResult(200, "OK");
    }

    @ApiOperation(value = "删除灌注符", notes = "根据灌注符ID删除灌注符信息")
    @PostMapping("/delete")
    public JsonResult deleteInlay(@ApiParam(value = "灌注符信息") @RequestBody Inlay inlay) {
        inlayServer.deleteInlay(inlay.getId());
        return new JsonResult(200, "OK");
    }

    @ApiOperation(value = "获取所有灌注符", notes = "获取系统中所有灌注符信息")
    @GetMapping("/all")
    public JsonResult getAllInlay() {
        return new JsonResult(200, "OK", inlayServer.getAllInlay());
    }

    @ApiOperation(value = "按部位筛选灌注符", notes = "根据装备部位获取对应的灌注符信息")
    @GetMapping("/filter/{slot}")
    public JsonResult getInlayBySlot(@ApiParam(value = "装备部位") @PathVariable String slot) {
        return new JsonResult(200, "OK", inlayServer.getInlayBySlot(slot));
    }

    @ApiOperation(value = "获取灌注符详情", notes = "根据灌注符ID获取详细信息")
    @GetMapping("/{id}")
    public JsonResult getInlayById(@ApiParam(value = "灌注符ID") @PathVariable int id) {
        return new JsonResult(200, "OK", inlayServer.getInlayById(id));
    }
}